package org.soar.views;

import java.util.Map;

import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager;

import com.google.inject.Inject;
import org.soar.SoarApplication;
import org.soar.helper.SoarHelper;

public class SoarDialog extends Dialog {

	protected Map data = null;
	protected Context context = null;
	@Inject
	private SoarHelper soarHelper;

	public SoarDialog(Context context, int layout, Map data, int width,int height) {
		super(context);
		this.data = data;
		this.context = context;
		((SoarApplication)context.getApplicationContext()).getInjector().injectMembers(this);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		// set content
		setContentView(layout);
		Window window = getWindow();
		Display d = window.getWindowManager().getDefaultDisplay();
		WindowManager.LayoutParams params = window.getAttributes();
		// set width,height by density and gravity
//		params.gravity = Gravity.CENTER;
		if(width != 0){
			params.width = width;
		}else{
			params.width = (int) (d.getWidth() * 0.9);
		}
		if(height != 0){
			params.height = height;
		}else{
			params.height = (int) (soarHelper.getDensity() * 250);
		}
		window.setAttributes(params);
		
		
		soarHelper.renderMembersWithAnnotationForDialog(this);
		
	}
	

}